#include "Eventfd.h"
#include <iostream>
#include <unistd.h>
#include <thread>
using std::cout;
using std::endl;
using std::thread;

class MyTask
{
public:
    void process()
    {
        cout << "MyTask process is running" << endl;
    }
};

void test0(){
    MyTask task;
    Eventfd efd(bind(&MyTask::process,&task));
    
    //子线程监听eventfd
    thread th(bind(&Eventfd::start,&efd));

    //主线程对eventfd进行了10次写操作
    int cnt = 10;
    while(cnt--)
    {
        efd.wakeup();
        sleep(1);
    }

    efd.stop();
    th.join();


}

int main(void){
    test0();
    return 0;
}

